Check for the existence of Cargo.toml when reading packages.
authorHuon Wilson <dbau.pp+github@gmail.com>
Sat, 28 Jun 2014 09:25:32 +0000 (19:25 +1000)
committerHuon Wilson <dbau.pp+github@gmail.com>
Mon, 30 Jun 2014 00:42:08 +0000 (10:42 +1000)
Fixes #82.

src/cargo/ops/cargo_read_manifest.rs
tests/test_cargo_compile_path_deps.rs

index 324085734f2c590ec8690eed8e306f34b57b716e..262e502af9e6d60fcfa54d8b7ad3f387a60df725 100644 (file)
@@ -1,7 +1,7 @@
 use std::io::File;
 use util;
 use core::{Package,Manifest,SourceId};
-use util::{CargoResult, human};
+use util::{CargoResult, human, important_paths};
 
 pub fn read_manifest(contents: &[u8], source_id: &SourceId)
     -> CargoResult<(Manifest, Vec<Path>)>
@@ -24,7 +24,8 @@ pub fn read_package(path: &Path, source_id: &SourceId)
 pub fn read_packages(path: &Path, source_id: &SourceId)
     -> CargoResult<Vec<Package>>
 {
-    let (pkg, nested) = try!(read_package(&path.join("Cargo.toml"), source_id));
+    let manifest = try!(important_paths::find_project_manifest_exact(path, "Cargo.toml"));
+    let (pkg, nested) = try!(read_package(&manifest, source_id));
     let mut ret = vec!(pkg);
 
     for p in nested.iter() {
index f01a1854950e7ee4bfa629850232fca80c1f2d0c..7b4406eb9dbea687ea8c52b1856d6b2209bba5a7 100644 (file)
@@ -354,3 +354,26 @@ test!(nested_deps_recompile {
                                             FRESH, bar.display(),
                                             COMPILING, p.root().display())));
 })
+
+test!(error_message_for_missing_manifest {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [project]
+
+            name = "foo"
+            version = "0.5.0"
+            authors = ["wycats@example.com"]
+
+            [dependencies.bar]
+
+            path = "src/bar"
+        "#)
+       .file("src/bar/not-a-manifest", "");
+
+    assert_that(p.cargo_process("cargo-build"),
+                execs()
+                .with_status(101)
+                .with_stderr(format!("Could not find `Cargo.toml` in `{}`\n",
+                                     p.root().join_many(&["src", "bar"]).display())));
+
+})